package com.jms.consumer;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MapMessage;

import org.springframework.jms.core.JmsTemplate;

public class ConsumerServiceImpl implements ConsumerService {
	
	private JmsTemplate jmsTemplate;
	
	private Destination destination;
	
	public Destination getDestination() {
		return destination;
	}

	public void setDestination(Destination destination) {
		this.destination = destination;
	}

	public JmsTemplate getJmsTemplate() {
		return jmsTemplate;
	}

	public void setJmsTemplate(JmsTemplate jmsTemplate) {
		this.jmsTemplate = jmsTemplate;
	}

	@Override
	public void receive() {
		
		MapMessage msg = (MapMessage) jmsTemplate.receive(this.destination);
		
		try {
			System.out.println("收到一条消息："+msg.getString("time"));
		} catch (JMSException e) {
			e.printStackTrace();
		}

	}

}
